package cn.engage.basic.controller;



import cn.engage.basic.dto.MailRegisterDto;
import cn.engage.basic.dto.PhoneRegisterDto;
import cn.engage.basic.service.RegisterService;
import cn.engage.basic.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/register")
public class RegisterController {

    @Autowired
    private RegisterService registerService;

    /**
     * 手机号注册
     */
    @PostMapping("/phone")
    public AjaxResult phoneRegister(@RequestBody @Valid PhoneRegisterDto dto){

        registerService.phoneRegister(dto);

        return AjaxResult.me().success();
    }
    /**
     * 邮箱注册保存到数据库
     */
    @PostMapping("/mail")
    public AjaxResult getMailCode(@RequestBody @Valid MailRegisterDto dto){
        registerService.MailRegister(dto);
        return AjaxResult.me().success();
    }
}
